package com.runda.partypolicy.app.page.fragment.home;



import android.os.Bundle;

import android.view.View;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;


import com.runda.partypolicy.R;
import com.runda.partypolicy.app.base.BaseFragment;
import com.runda.partypolicy.app.page.adapter.MyFragmentPagerAdapter;
import com.runda.partypolicy.app.page.fragment.office.Fragment_Office_First;
import com.runda.partypolicy.app.page.fragment.office.Fragment_Office_Second;
import com.runda.partypolicy.app.page.viewmodel.ViewModel_Main_Office;
import com.runda.partypolicy.app.repository.bean.ItemData;

import java.util.ArrayList;
import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;
import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;

public class Fragment_Main_Office extends BaseFragment<ViewModel_Main_Office> {
    List<ItemData> dataList = new ArrayList<>();
    @BindView(R.id.commen_title_name)
    TextView commenTitleName;
    @BindView(R.id.commen_title_img)
    ImageView commenTitleImg;
    @BindView(R.id.commen_title_back)
    ImageView commenTitleBack;
    @BindView(R.id.commen_title_start)
    ImageView commenTitleStart;
    @BindView(R.id.commen_search_img)
    ImageView commenSearchImg;
    @BindView(R.id.office_viewpager)
    ViewPager officeViewpager;

    List<Fragment> list = new ArrayList<>();
    @BindView(R.id.office_rg)
    RadioGroup officeRg;


    public static Fragment_Main_Office newInstance() {
        Bundle args = new Bundle();
        Fragment_Main_Office fragment = new Fragment_Main_Office();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayout() {
        return R.layout.fragment_office;
    }

    @Override
    public ViewModel_Main_Office initViewModel() {
        return ViewModelProviders.of(this,getViewModelFactory()).get(ViewModel_Main_Office.class);
    }

    @Override
    public void initEvents() {

    }

    @Override
    public void start() {
        commenSearchImg.setVisibility(View.VISIBLE);

        commenTitleName.setText("办公");
        init();
    }

    @Override
    public void initNotSignEvent() {

    }

    @Override
    public void initNoNetworkEvent() {

    }

    @Override
    public void initShowMessageEvent() {

    }

    @Override
    public void initTokenOverTimeEvent() {

    }

    @Override
    public void initShowOrDismissWaitingEvent() {

    }

    @Override
    public void initStateLayoutEvent() {

    }

    private void init() {
        Fragment_Office_First officeFirst = Fragment_Office_First.newInstance();
        Fragment_Office_Second officeSecond = Fragment_Office_Second.newInstance();
        list.add(officeFirst);
        list.add(officeSecond);
        officeRg.check(R.id.rt_first);
        officeViewpager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), list));
        officeViewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {

                if (position == 0) {
                    officeRg.check(R.id.rt_first);
                } else if (position == 1){
                    officeRg.check(R.id.rt_second);
                }

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }


}
